﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
    Layout = null;
}

<link href="~/lib/layui/css/layui.css" rel="stylesheet" />
<script src="~/lib/layui/layui.js"></script>
<script src="~/js/js.cookie.js"></script>
<script src="~/js/moment.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Demo</title>
    <!-- 请勿在项目正式环境中引用该 layui.css 地址 -->
    <link href="//unpkg.com/layui@2.9.18/dist/css/layui.css" rel="stylesheet">
</head>
<body>
    <form class="layui-form" action="">
        <h3>分娩提示列表</h3>
        <div class="layui-form-item">
            <div class="layui-form-item">

                <table class="layui-table">
                    <thead>
                        <tr>
                            <td>序号</td>
                            <td>种母耳号</td>
                            <td>空杯天数</td>
                            <td>栋舍</td>
                            <td>栏位</td>
                            <td>繁殖状态</td>
                            <td>事件日期</td>
                            <td>类型</td>
                        </tr>
                    </thead>
                    <tbody></tbody>
                </table>
                <div id="demo-laypage-all"></div>



            </div>

        </div>
    </form>

    <!-- 请勿在项目正式环境中引用该 layui.js 地址 -->
    <script src="//unpkg.com/layui@2.9.18/dist/layui.js"></script>
    <script>
        var form = layui.form;
        var $ = layui.jquery;

        layui.use(function () {
            var laypage = layui.laypage;
            var pageIndex = 1;
            var pageSize = 5;

            var $ = layui.$;
            var layer = layui.layer;
            var util = layui.util;

            Show();


            //分娩提示列表
            function Show() {

                $.post({
                    url: 'http://localhost:5269/api/SheepArchive/ChildbirthTipQuery',
                    data: JSON.stringify
                        ({
                            pageIndex: pageIndex, pageSize: pageSize
                        }),
                    async: false,
                    dataType: "json",
                    contentType: "application/json",
                    success: res => {
                        var count = "";

                        // var aa = moment(this.dieDate).format("YYYY-MM-DD HH:mm:ss")
                        // var bb = this.dieReason == 1 ? "腹泻" : this.dieReason == 2 ? "肺炎" : this.dieReason == 3 ? "发热" : "猝死";
                        // var cc = this.sheepSex == 0 ? "公" : "母";
                        var dd = moment(this.breedingsettingTime).format("YYYY-MM-DD HH:mm:ss")

                        $.each(res.data, function () {

                            count += `<tr>
                                                 <td>${this.pregnancyTestId}</td>
                                                   <td>${this.recordAuricle}</td>
                                                   <td>${this.fieldId}</td>
                                                   <td>${this.cottageId}</td>
                                                   <td>${this.cottageName}</td>
                                                   <td>${this.fieldName}</td>
                                                   <td>${dd}</td>
                                                   <td>${this.pregnancyDays}</td>
                            </tr>
                           `
                        })
                        //pagedCount = res.pagedCount;
                        //pcount = res.totalCount;
                        $("tbody").html(count)
                        // console.log(res.data)

                        //var page = Math.ceil(res.totalCount / 5);  //总页数
                        console.log(996, pageSize, pageIndex, res);
                        // 完整显示
                        laypage.render({
                            elem: 'demo-laypage-all', // 元素 id
                            curr: pageIndex,//当前页
                            pages: res.pagedCount,    //总页数
                            limit: pageSize,//每页几条
                            limits: [5, 10, 15],
                            count: res.totalCount, // 数据总数
                            layout: ['count', 'prev', 'page', 'first', 'last', 'next', 'limit', 'skip'], // 功能布局
                            jump: function (obj, first) {
                                if (!first) {
                                    console.log(888, obj);
                                    console.log(obj.curr); // 得到当前页，以便向服务端请求对应页的数据。
                                    console.log(obj.limit); // 得到每页显示的条数
                                    pageIndex = obj.curr;
                                    pageSize = obj.limit;
                                    Show();
                                }
                            }
                        });
                    }
                })


            }

        });
    </script>
</body>
</html>

<script>


</script>